package top.dancun.easgetaway.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;


@Configuration
public class CorsConfiguration  {

    @Bean
    public CorsWebFilter corsWebFilter(){
        UrlBasedCorsConfigurationSource corsSource = new UrlBasedCorsConfigurationSource();
        org.springframework.web.cors.CorsConfiguration conf = new org.springframework.web.cors.CorsConfiguration();
        conf.addAllowedHeader("*");
        conf.addAllowedOriginPattern("*");
        conf.addAllowedMethod("*");
        conf.setAllowCredentials(true);
        corsSource.registerCorsConfiguration("/**",conf);
        return  new CorsWebFilter(corsSource);

    }
}
